package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.NetworkExamineList;
import com.ruoyi.logistic.domain.NetworkExamineSetting;
import com.ruoyi.logistic.domain.NetworkExamineType;
import com.ruoyi.logistic.mapper.NetworkExamineTypeMapper;
import com.ruoyi.logistic.service.NetworkExamineListService;
import com.ruoyi.logistic.service.NetworkExamineSettingService;
import com.ruoyi.logistic.service.NetworkExamineTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/network/examine")
@RestController
@Api(tags = "网点财务_考核分摊结算")
public class NetworkExamineController {
    @Autowired
    private NetworkExamineListService networkExamineListService;
    @Autowired
    private NetworkExamineTypeService networkExamineTypeService;
    @Autowired
    private NetworkExamineSettingService networkExamineSettingService;

    @ApiOperation("显示考核分摊结算左侧列表")
    @GetMapping("/selectExamineListAll")
    public R selectExamineListAll(){
        List<NetworkExamineList> networkExamineLists = networkExamineListService.selectAll();
        if (networkExamineLists == null || networkExamineLists.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(networkExamineLists);
        }
    }
    @ApiOperation("添加考核分摊结算左侧数据")
    @PostMapping("/insert")
    public R insert(@RequestBody NetworkExamineList networkExamineList){
        Boolean isAdd = networkExamineListService.insert(networkExamineList);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }
    @ApiOperation("修改考核分摊结算左侧数据")
    @PostMapping("/update")
    public R update(@RequestBody NetworkExamineList networkExamineList){
        Boolean isUpdate = networkExamineListService.update(networkExamineList);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }
    @ApiOperation("删除考核分摊结算左侧数据")
    @PostMapping("/deleteById")
    public R deleteById(Integer id){
        Boolean isDelete = networkExamineListService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
    @ApiOperation("显示考核方式下拉框")
    @GetMapping("/selectExamineTypeAll")
    public R selectExamineTypeAll(){
        List<NetworkExamineType> networkExamineTypes = networkExamineTypeService.selectAll();
        if (networkExamineTypes == null || networkExamineTypes.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(networkExamineTypes);
        }
    }
    @ApiOperation("批量添加")
    @PostMapping("/insertList")
    @ResponseBody
    public R insertList(List<NetworkExamineSetting> list){
        return R.ok(networkExamineSettingService.insertList(list));
    }
}
